Skip to content

Conversation

@fellyph
Copy link
Collaborator

@fellyph fellyph commented Oct 14, 2025

This pull request updates the documentation and usage examples for the PHP WASM library to use the new runStream method instead of the deprecated run method, reflecting recent API changes. These updates ensure that users and developers are guided to use the latest recommended approach for executing PHP code and handling output streams.

Documentation and Example Updates:

  • Updated the JavaScript API Playground documentation to use php.runStream in both English and Portuguese versions, replacing the previous php.run method.
  • Revised the Node.js README example to use php.runStream and updated the output handling to use output.stdoutText instead of response.text.
  • Modified the Web README example to use php.runStream for running scripts, ensuring consistency with the new API.

@fellyph fellyph requested a review from adamziel October 14, 2025 12:48
@fellyph fellyph marked this pull request as ready for review October 14, 2025 12:48
@fellyph fellyph added the [Type] Documentation Improvements or additions to documentation label Oct 14, 2025
@mho22
Copy link
Collaborator

mho22 commented Oct 14, 2025

@fellyph @adamziel For the @php-wasm/web package, I suggested a new example in the last pull request of Adam : #2776 (comment).

Because some other things are deprecated as well.

@fellyph
Copy link
Collaborator Author

fellyph commented Oct 14, 2025

@mho22 I'm updating the documentation, and I'm finding more examples deprecated. I will move it to draft and add more items.

@fellyph
Copy link
Collaborator Author

fellyph commented Oct 14, 2025

@mho22 running the code locally I got the following error:


node:internal/modules/run_main:123
    triggerUncaughtException(
    ^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".wasm" for /Users/fellyph/node_modules/@php-wasm/web/php/asyncify/8_0_30/php_8_0.wasm
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:219:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:245:36)
    at defaultLoad (node:internal/modules/esm/load:120:22)
    at async nextLoad (node:internal/modules/esm/hooks:748:22)
    at async load (file:///Users/fellyph/.nvm/versions/node/v22.16.0/lib/node_modules/tsx/dist/esm/index.mjs?1760465490117:2:1771)
    at async nextLoad (node:internal/modules/esm/hooks:748:22)
    at async Hooks.load (node:internal/modules/esm/hooks:385:20)
    at async handleMessage (node:internal/modules/esm/worker:199:18) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Node.js v22.16.0

@mho22
Copy link
Collaborator

mho22 commented Oct 14, 2025

Ah yes, sorry @fellyph, it is related to this : #2776 (comment)

You'll need add that in your vite.config.js file.

@fellyph
Copy link
Collaborator Author

fellyph commented Oct 15, 2025

@mho22 I have set it up, it's fine. You can review the changes now. Are the demos running

@fellyph fellyph requested a review from mho22 October 15, 2025 07:22
@mho22
Copy link
Collaborator

mho22 commented Oct 15, 2025

@mho22 running the code locally I got the following error:


node:internal/modules/run_main:123
    triggerUncaughtException(
    ^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".wasm" for /Users/fellyph/node_modules/@php-wasm/web/php/asyncify/8_0_30/php_8_0.wasm
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:219:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:245:36)
    at defaultLoad (node:internal/modules/esm/load:120:22)
    at async nextLoad (node:internal/modules/esm/hooks:748:22)
    at async load (file:///Users/fellyph/.nvm/versions/node/v22.16.0/lib/node_modules/tsx/dist/esm/index.mjs?1760465490117:2:1771)
    at async nextLoad (node:internal/modules/esm/hooks:748:22)
    at async Hooks.load (node:internal/modules/esm/hooks:385:20)
    at async handleMessage (node:internal/modules/esm/worker:199:18) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Node.js v22.16.0

I faced the same issue during the review because I tried to run the file with Node. I now understand how you got this.

@fellyph fellyph merged commit 0356d50 into trunk Oct 15, 2025
28 checks passed
@fellyph fellyph deleted the updating-run-wasm-method branch October 15, 2025 13:14
@adamziel
Copy link
Collaborator

Lovely collaboration @mho22 @fellyph!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants